#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
#   GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
#   Author :  Shawn.Tan
#   Date : 2025.10.28
#
#   History : Initial Version 2025.10.28
#
#


#  Made the given object sortable and comparable
class SortableObject(object):
    def __init__(self):
        # derived class MUST set up _mSortableName!
        self.mSortableName = ""

    def __hash__(self):
        return hash(self.mSortableName)

    def __eq__(self, other):
        if isinstance(other, SortableObject):
            return self.mSortableName == other.mSortableName
        elif isinstance(other, str):
            return self.mSortableName == other
        else:
            return NotImplemented

    def __lt__(self, other):
        if isinstance(other, SortableObject):
            return self.mSortableName < other.mSortableName
        elif isinstance(other, str):
            return self.mSortableName < other
        else:
            return NotImplemented

    def __gt__(self, other):
        if isinstance(other, SortableObject):
            return self.mSortableName > other.mSortableName
        elif isinstance(other, str):
            return self.mSortableName > other
        else:
            return NotImplemented

    def __ne__(self, other):
        if isinstance(other, SortableObject):
            return not (self.mSortableName == other.mSortableName)
        elif isinstance(other, str):
            return not (self.mSortableName == other)
        else:
            return NotImplemented
